package priv.mill.fanxing;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

public class Test01 {

	private static final Logger logger = Logger.getLogger(Test01.class);
	public static void main(String[] args) {
		
		/**
		 * 类型参数
		 * l/不能用基本类型
		 */
		List<? extends Object> tempList=new ArrayList<Object>();
		tempList.add(null);
//		tempList.add(4321431);
		
		
//		List<Integer> aaaIntegers=(List<Integer>)tempList;
		List<Object> ints=new ArrayList<Object>();
		ints.add(111111);
		ints.add(222222);
		ints.add("abc");
		
		List<Integer> convertList = convertList(ints,Integer.class);
		System.out.println(convertList);
	}
	
	public static <T> List<T> convertList(List<?> src,Class<T> clzz){
		List<T> result=new ArrayList<T>();
		for (Object object : src) {
			if(object.getClass().equals(clzz))
			result.add((T) object);
		}
		return result;
		
	}
	
}
